package Test

import org.apache.spark.storage.StorageLevel
import org.apache.spark.util.LongAccumulator
import org.apache.spark.{SparkConf, SparkContext}

object TestDemo3 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName("test")
    conf.setMaster("local")
    val context = new SparkContext(conf)
    val src = context.textFile("hdfs://hadoop102:8020/students.csv")
    src.persist(StorageLevel.MEMORY_AND_DISK_SER)
    val acc =  new LongAccumulator
    val srcRDD = src.map(line => {
      val sp = line.split(",")
      (sp(0), sp(1), sp(2), sp(3), sp(4))
    }).filter(_._5.contains("理科三班"))
    srcRDD.foreach(println)
  }
}
